]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ScreenShield: send a signal to GSD to wake up the screen
authorGiovanni Campagna <gcampagna@src.gnome.org>
Mon, 10 Mar 2014 18:16:03 +0000 (19:16 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Tue, 11 Mar 2014 17:10:05 +0000 (18:10 +0100)
Instead of poking through IDLETIME, which confuses the state tracking
and can prevent automatic suspend, send a special signal to GSD
when the screen is to be waken up for a notification.

Someday we'll bring over all the state tracking and avoid this
ping-pong between gnome-shell and gnome-settings-daemon, but
that day's not today.

https://bugzilla.gnome.org/show_bug.cgi?id=712706

js/ui/screenShield.js
js/ui/shellDBus.js
src/shell-util.c
src/shell-util.h

index c0e58b379e088b3fcb8a634fb42e789cc76f1e02..b1e1e7f8fcb838a587655a0e0a4b21058decf8c1 100644 (file)
@@ -301,7 +301,7 @@ const NotificationsBox = new Lang.Class({
                              });
 
             this._updateVisibility();
-            Shell.util_wake_up_screen();
+            this.emit('wake-up-screen');
         }
     },
 
@@ -327,7 +327,7 @@ const NotificationsBox = new Lang.Class({
 
         this._updateVisibility();
         if (obj.sourceBox.visible)
-            Shell.util_wake_up_screen();
+            this.emit('wake-up-screen');
     },
 
     _visibleChanged: function(source, obj) {
@@ -342,7 +342,7 @@ const NotificationsBox = new Lang.Class({
 
         this._updateVisibility();
         if (obj.sourceBox.visible)
-            Shell.util_wake_up_screen();
+            this.emit('wake-up-screen');
     },
 
     _detailedChanged: function(source, obj) {
@@ -380,6 +380,7 @@ const NotificationsBox = new Lang.Class({
         this._sources.delete(source);
     },
 });
+Signals.addSignalMethods(NotificationsBox.prototype);
 
 const Arrow = new Lang.Class({
     Name: 'Arrow',
@@ -1151,6 +1152,7 @@ const ScreenShield = new Lang.Class({
         this._lockScreenContents.add_actor(this._lockScreenContentsBox);
 
         this._notificationsBox = new NotificationsBox();
+        this._wakeUpScreenId = this._notificationsBox.connect('wake-up-screen', Lang.bind(this, this._wakeUpScreen));
         this._lockScreenContentsBox.add(this._notificationsBox.actor, { x_fill: true,
                                                                         y_fill: true,
                                                                         expand: true });
@@ -1158,11 +1160,17 @@ const ScreenShield = new Lang.Class({
         this._hasLockScreen = true;
     },
 
+    _wakeUpScreen: function() {
+        this._onUserBecameActive();
+        this.emit('wake-up-screen');
+    },
+
     _clearLockScreen: function() {
         this._clock.destroy();
         this._clock = null;
 
         if (this._notificationsBox) {
+            this._notificationsBox.disconnect(this._wakeUpScreenId);
             this._notificationsBox.destroy();
             this._notificationsBox = null;
         }
index 6dbb5aeb6b5c58611eade1b331c329c2b54dda3f..52e9fa8f6f688c2cbf68d7a15115f66df6a0f53f 100644 (file)
@@ -69,6 +69,7 @@ const ScreenSaverIface = '<node> \
 <signal name="ActiveChanged"> \
     <arg name="new_value" type="b" /> \
 </signal> \
+<signal name="WakeUpScreen" /> \
 </interface> \
 </node>';
 
@@ -407,6 +408,9 @@ const ScreenSaverDBus = new Lang.Class({
         screenShield.connect('active-changed', Lang.bind(this, function(shield) {
             this._dbusImpl.emit_signal('ActiveChanged', GLib.Variant.new('(b)', [shield.active]));
         }));
+        screenShield.connect('wake-up-screen', Lang.bind(this, function(shield) {
+            this._dbusImpl.emit_signal('WakeUpScreen', null);
+        }));
 
         this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenSaverIface, this);
         this._dbusImpl.export(Gio.DBus.session, '/org/gnome/ScreenSaver');
index 61676ecd90f6b8885351a4ef9f64845ce54d2524..5ae4fdb3c454e0f0851d0a8537db52d5ec611090 100644 (file)
@@ -313,33 +313,6 @@ shell_util_create_pixbuf_from_data (const guchar      *data,
                                    (GdkPixbufDestroyNotify) g_free, NULL);
 }
 
-/**
- * shell_util_wake_up_screen:
- *
- * Send a fake key event, resetting the IDLETIME counter and
- * causing gnome-settings-daemon to wake up the screen.
- */
-/* Shamelessly taken from gnome-settings-daemon/plugins/power/gpm-common.c */
-void
-shell_util_wake_up_screen (void)
-{
-  static gboolean inited = FALSE;
-  static KeyCode keycode1, keycode2;
-  static gboolean first_keycode = FALSE;
-
-  if (inited == FALSE) {
-    keycode1 = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), GDK_KEY_Alt_L);
-    keycode2 = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), GDK_KEY_Alt_R);
-  }
-
-  gdk_error_trap_push ();
-  /* send a left or right alt key; first press, then release */
-  XTestFakeKeyEvent (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), first_keycode ? keycode1 : keycode2, True, CurrentTime);
-  XTestFakeKeyEvent (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), first_keycode ? keycode1 : keycode2, False, CurrentTime);
-  first_keycode = !first_keycode;
-  gdk_error_trap_pop_ignored ();
-}
-
 void
 shell_util_cursor_tracker_to_clutter (MetaCursorTracker *tracker,
                                       ClutterTexture    *texture)
index fdaec560acab49f21f2937caac52f78ae5583e81..d7ab4fdcf6f79aafe193bfc33dbd2fc614d1878d 100644 (file)
@@ -41,8 +41,6 @@ GdkPixbuf *shell_util_create_pixbuf_from_data (const guchar      *data,
                                                int                height,
                                                int                rowstride);
 
-void    shell_util_wake_up_screen             (void);
-
 void    shell_util_cursor_tracker_to_clutter (MetaCursorTracker *tracker,
                                               ClutterTexture    *texture);